#!/usr/bin/python
# -*- coding:UTF8 -*-
# 如何将snums 转为 list ["10","20","30","45","23"]
snums = '10,20,30,40,50,60'
print(snums.split(','))
print(snums.split())
print(snums.split(',', 2))
listA = ['10', '20', '30,40,50,60']
str(listA)
print(type(str(listA)))
num = ','.join(listA)
print(type(num), num)
names = ["xiaoming", "xiaowang", "xiaozhang"]
print('**'.join(names))

# 字典类型数据转换
user = {
    "name": "小白",
    "age": 23,
    "wechat": "xxxxxx"
}
print(list(user.items()))

# list 格式的数据转换为字典
k1 = ('name', 'mr.liu')
k2 = ('age', '28')
k3 = ('work', 'san')
print(list([k1, k2, k3]))
k1 = ('id', 'name')
k2 = ('25', '象牙山小诸葛')
print(dict(list(zip(k1, k2))))

words = ["he", "i", "she", "he", "i", "hello"]
wset = set(words)
print(wset)
for i in wset:
    print(i, words.count(i))
a = "abcabcefsssff"
print(set(a))
b = ''
for i in set(a):
    b = b + i
print(b)

test_data = {
    "test_topic": {
        "method": "Get",
        "url": "http://49.233.108.117:3000/api/v1/topics",
        "data": {
            "page": 1,
            "tab": "ask",
            "limit": 1,
            "mdrender": "true"
        }
    },
    "test_create_topics": {
        "method": "Post",
        "url": "http://49.233.108.117:3000/api/v1/topics",
        "data": {
            "accesstoken": "xxxxxxxxxxx",
            "title": "askxxxxxxxxxx",
            "tab": "ask",
            "content": "xxxxxxxx"
        }
    }
}
# 循环字典
for test_title, test_value in test_data.items():
    # print('测试的标题为：', test_title)
    # print('测试的内容为：', test_value)
    requests_method = test_value.get('method')
    print('请求的方法为：', requests_method)
    requests_url = test_value.get('url')
    print('请求的地址为：', requests_url)
    requests_data = test_value.get('data')
    print('请求的数据为：', requests_data)
